package experiment;

public class Complex {
    private int RealPart;//实数部分
    private int ImaginPart;//虚数部分

    public int getRealPart() {
        return RealPart;
    }
    public void setRealPart(int r) {
        this.RealPart = r;
    }
    public int getImaginPart() {
        return ImaginPart;
    }
    public void setImaginPart(int i) {
        this.ImaginPart = i;
    }

    public Complex(int r, int i) {
        this.RealPart = r;
        this.ImaginPart = i;
    }

    public Complex() {
        RealPart = 0;
        ImaginPart = 0;
    }

    public static Complex complexAdd(Complex a, Complex b){
        Complex c = new Complex();
        c.RealPart = a.RealPart+b.RealPart;
        c.ImaginPart = a.ImaginPart+b.ImaginPart;
        return c;
    }
    public static String ToString(Complex a){
       return a.RealPart+"+"+a.ImaginPart+"i";
    }

    public static void main(String[] args) {
        Complex a,b;
        Complex c1 = new Complex(1,1);
        Complex c2 = new Complex(0,2);
        System.out.println(Complex.ToString(complexAdd(c1,c2)));
    }
}
